home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_07_01
/
v7n1064a.txt
< prev
next >
Wrap
Text File
|
1988-09-12
|
849b
|
46 lines
/* try.c try the dir_retrieve() and dir_free routines.
* get a directory listing, print it and the file count.
*
* (c) Copyright 1988 Aspen Scientific
* All Rights Reserved.
*/
#include "dirret.h"
int
main(argc, argv)
int argc;
char **argv;
{
register int i;
struct dir_retrieve_t *dir;
char *try;
int dir_entries;
/* use either the command line argument,
* or the default - the current dir (".").
*/
if (argc == 1)
try = ".";
else
try = argv[1];
dir = dir_retrieve( try, &dir_entries );
if (dir == (struct dir_retrieve_t *)0) {
/* print error with errno string */
perror("dir_retrieve");
exit(2);
}
for (i=0; i < dir_entries; ++i)
printf("%s%c\n", dir[i].name, (dir[i].subdir ? '/':'\0'));
printf("\t%d File(s)\n", dir_entries);
dir_free( dir );
exit(0);
}